﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title</title>
        @Using(SystemDirectory.Utility, "scripts/jquery-1.6.2.min.js")
        @Using(SystemDirectory.Utility, "scripts/modernizr-1.7.min.js")
        @Using(SystemDirectory.Utility, "scripts/jquery-ui-1.8.16.custom.min.js")
        @Using(SystemDirectory.Utility, "scripts/global.js")
        @Using(SystemDirectory.Scripts, "core.js")
        @Using(SystemDirectory.Utility, "pepper-grinder/jquery-ui-1.8.16.custom.css")
        @Using(SystemDirectory.Utility, "common.css")
        @Using(SystemDirectory.Content, "core.css")
        @RenderSection("header", false)
    </head>
    <body>
        <div class="header">
            @Html.IconButtonLink(Local("WebHomePage"), "home", CommonUrls.DefaultUrl)
            @Html.IconButtonLink(GLocal("UserCenter"), "key", CommonUrls.UCDefaultUrl)
            @Html.IconButtonLink(Local("ControlPanel"), "wrench", CUrls.DefaultUrl, Controller.IsMatched("home"))
            @Html.IconButtonLink(Local("UserManagement"), "person", CUrls.UCenterView, Controller.IsMatched("ucenter"))
            @Html.IconButtonLink(Local("ForumManagement"), "suitcase", CUrls.ForumsView, Controller.IsMatched("forum"), Permission.IsAllowed(Permission.AllowForumManagement))
            @Html.IconButtonLink(Local("HostManagement"), "bookmark", CUrls.HostIndex, Controller.IsMatched("host"), Permission.IsAllowed(Permission.AllowHostManagement))
            @Html.IconButtonLink(Local("ResetApplication"), "lightbulb", null, false, Permission.IsAllowed(Permission.AllowResetApplication), new { @onclick = "return openModal('" + CUrls.ResetApplication + "', 300);" })
            @Html.IconButtonLink(Self.NickName + "，" + GLocal("User.Logout"), "power", CommonUrls.Logout, false, true, new { @style = "float:right" })
        </div>
        <div class="main">
            <div class="mright">
                <div class="rcontainer">
                    <div class="title">@ViewBag.Title</div>
                    @CPHelper.ShowStatus(ViewBag)
                    @RenderBody()
                </div>
            </div>
            <div class="mleft">
                @if ("home".IsMatched(Controller))
                {
                <div class="left-title">@Local("ControlPanel")</div>
                <ul class="menu">
                    @AddSubMenu("index", "ControlPanelHomePage", CUrls.DefaultUrl)
                    @AddSubMenu("commonview", "ApplicationConfiguration.PageTitle", CUrls.CommonView)
                    @AddSubMenu("threadsview", "ThreadsManagement", CUrls.ThreadsView)
                    @AddSubMenu("categoryview", "CategoriesView.PageTitle", CUrls.CategoryView)
                    @AddSubMenu("themeview", "ThemeView.PageTitle", CUrls.ThemeView)
                </ul>
                }
                else if ("host".IsMatched(Controller) && Permission.IsAllowed(Permission.AllowHostManagement))
                { 
                <div class="left-title">@Local("HostSettings")</div>
                <ul class="menu">
                    @AddSubMenu("index", "SitesManagement", CUrls.HostIndex)
                    @AddSubMenu("urlview", "UrlRouteManagement", CUrls.HostUrlView)
                    @AddSubMenu("settingview", "SiteSettingsManagement", CUrls.HostSettingView)
                    @AddSubMenu("appview", "ApplicationManagement", CUrls.HostAppView)
                    @AddSubMenu("controlpanelview", "SecurityConfiguration.PageTitle", CUrls.HostControlpanelView)
                    @AddSubMenu("permissionview", "SecurityPermission", CUrls.HostPermissionView)
                    @AddSubMenu("taskview", "TaskManagement", CUrls.HostTaskView)
                    @AddSubMenu("logview", "LogManagement", CUrls.HostLogView)
                </ul>
                }
                else if ("ucenter".IsMatched(Controller))
                { 
                <div class="left-title">@Local("UserManagement")</div>
                <ul class="menu">
                    @AddSubMenu("ucenterview", "UCenterConfiguration.PageTitle", CUrls.UCenterView)
                    @AddSubMenu("rolesview", "Roles.PageTitle", CUrls.UCenterRolesView)
                    @AddSubMenu("permissionview", "UCenterPermission", CUrls.UCenterPermissionView)
                </ul>
                }
                else if ("forum".IsMatched(Controller))
                { 
                <div class="left-title">@Local("ForumManagement")</div>
                <ul class="menu">
                    @AddSubMenu("forumsview", "ForumsView.PageTitle", CUrls.ForumsView)
                    @AddSubMenu("settingsview", "DiscussConfiguration.PageTitle", CUrls.ForumSettingsView)
                    @AddSubMenu("permissionschemaview", "PermissionSchemaView.PageTitle", CUrls.ForumPermissionSchemaView)
                </ul>
                }
            </div>
            <div class="clear"></div>
        </div>
        <iframe frameborder="0" scrolling="no" id="dialog-container"/>
    </body>
</html>

@helper AddSubMenu(string action, string display, string url)
{
    <li @if (action.IsMatched(Action) || action.IsMatched(ViewBag.ActionMenu as string))
        {<text>class="current" </text>}><a href="@url">@Local(display)</a></li>
}